home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 1994-04-25 | 6.5 KB | 239 lines |
- >!RunImage
- Program Test Program For ASCII printing via Printer Drivers
- init
- quit%:
- start of poll loop
- "Wimp_Poll",0,bk%
- reason%
- reason%
- 6 :
- button
- 9 :
- menuselect
- 17,18:
- message
- 19 :
- messageack :
- in this case, bounced messages..
- "Wimp_CloseDown"
- button
- bk%!8
- read button state
- bk%!12=-2
- 5
- if Menu pressed over iconbar, create menu
- 0
- "Wimp_CreateMenu",,menu%,!bk%-64,184
- bk%!12
-
- ,
- <SELECT> used on iconbar icon..
-
- SendPrintSave
- menuselect
- button%
- "Wimp_GetPointerInfo",,bk%+256
- read button state
- (+button%=bk%!264
- !bk%
- quit if item 1 chosen
- ,$ quit%=
-
- re-open menu if Adjust was pressed
- button%=1
- "Wimp_CreateMenu",,menu%:
- message
- bk%!16
- 4G
- read message action code
- 0:quit%=
- :
- quit if Quit message received
- DataSaveAck:
- Message_DataSaveAck received
- messageack
- bk%!8 = my_ref%
- Message_PrintSave bounced, !Printers not running so error out
- of program (not very polite)..
- 99,"Printers not running!"
- string(a%)
- convert a null-terminated string into CR-terminated
- ?a%<>0
- a$+=
- ?a%:a%+=1
- bk% 511,menu% 75,ind% 255,name% 11
- quit%=0:name$="PrintTest"
- err%=0
- "OS_ReadVarVal","PrintTest$Dir",bk%,255,0,3
- ,,i%
- bk%?i%=13:dir$=$bk%
- "Wimp_Initialise",200,&4B534154,name$
- error:
- "Wimp_OpenTemplate",,dir$+".Templates"
- i%=ind%
- infohan%=
- create("InfoBox")
- "Wimp_CloseTemplate"
- W&!bk%=-1:bk%!4=0:bk%!8=0:bk%!12=100
- X1bk%!16=68:bk%!20=&3002:$(bk%+24)="!printtest"
- "Wimp_CreateIcon",,bk%
- setupmenu(menu%)
- setupmenu(m%)
- $m%,num%:len%=
- ($m%)-2
- _!m%!12=&70207:m%!20=44:m%!24=0
- m%+=28:
- i%=1
- num%
- !m%=-&80*(i%=num%):
- m%!4
- b# m%!8=&7009021:
- a$:$(m%+12)=a$
- a$>len% len%=
- m%+=24
- :menu%!16=16*(len%+1)
- create(a$)
- $name%=a$
- "Wimp_LoadTemplate",,bk%,i%,ind%+256,-1,name%,0
- ,,i%
- "Wimp_CreateWindow",,bk%
- handle%
- =handle%
- error
- report(
- $+" - internal error code "+
- "Wimp_CloseDown"
- report(a$,x%)
- !bk%=1:$(bk%+4)=a$+
- "Wimp_ReportError",bk%,x%,name$
- PrintTest,2,infohan%,Info,-1,Quit
- --- Printing Handling Routines ----------------------------------------
- SendPrintSave
- msgblk%,leaf$
- Initiates Printer protocol, causes a Message_DataSaveAck to be
- returned by !Printers if all is ok, else message bounces
- leaf$ = "PrintOut"+
- 7msgblk% =
- _heap_get(256) :
- get a memory block
- =msgblk%!00 = 256 :
- length of message block
- 9msgblk%!12 = 0 :
- myref 0=originating
- @msgblk%!16 = &80142 :
- message action (PrintSave)
- ?msgblk%!20 = 0 :
- destination window handle
- =msgblk%!24 = 0 :
- destination icon handle
- 3msgblk%!28 = 0 :
- mouse x coord
- 3msgblk%!32 = 0 :
- mouse y coord
- Jmsgblk%!36 = 256 :
- estimated size of file (wild guess!)
- 6msgblk%!40 = &FFF :
- file type (text)
- A$(msgblk% + 44) = leaf$ :
- suggested leaf name of file
- "Wimp_SendMessage",18,msgblk%,msgblk%!20,msgblk%!24
- store the unique wimp-generated 'my_ref' so that if the message is
- 'bounced' (i.e. !Printers isn't running) we can check when a
- _User_Message_Acknowledge (reason code 19) is received that it really
- is this messages that has been returned unanswered..
- my_ref% = msgblk%!8
- _heap_release(msgblk%)
- DataSaveAck
- name$,file%,msgblk%,a%,b%
- 4msgblk% =
- _heap_get(256) :
- get a memory block
- > :
- retrieve the full file name
- a% = 0 : b% = bk%?(44 + a%)
- b% <> 0
- name$ +=
- a% += 1
- b% = bk%?(44 + a%)
- 99,name$
- file% =
- (name$)
- # file%,"This is a printer test file.."
- # file%,&0D
- # file%,27:
- # file%,%10000001
- # file%,"And now in bold (hopefully!)"
- # file%,27:
- # file%,%10000000
- # file%,"And now bold IS OFF)"
- >cond$=
- &1F+"9201" :
- part of a FWP file!
- # file%,cond$
- # file%,"And now in CONDENSED HOPEFULLY!"
- # file%,27:
- # file%,%10000001 :
- Bold on
- # file%,"And now in condensed and ";
- # file%,27:
- # file%,%10001000 :
- Bold off, underline on
- # file%,"underlined";
- # file%,27:
- # file%,%10000000 :
- under off
- # file%," (hopefully!)"
- # file%
- msgblk%!00 = 256
- msgblk%!12 = my_ref%
- 0msgblk%!16 = 3 :
- reason code DataLoad
- ?msgblk%!20 = bk%!20 :
- window handle from original message
- ?msgblk%!24 = bk%!24 :
- icon handle from original message
- #msgblk%!36 =
- FileLength(name$)
- msgblk%!40 = &FFF
- #$(msgblk% + 44) = name$ +
- "Wimp_SendMessage",18,msgblk%,bk%!20,bk%!24
- _heap_release(msgblk%)
- --- Memory Management Routines ----------------------------------------
- _heap_get(size%)
- ptr%,heap%,flags%
- Returns pointer to new memory block unless claim fails
- in which case -1 is returned
- First find start address of RMA..
- "OS_ReadDynamicArea",1
- heap%
- Now claim memory, trapping errors by using X form of SWI..
- "XOS_Module",6,,,size%
- ,,ptr%;flags%
- If error occured return -1, else return address of allocated
- block
- (flags%
- ptr% = -1
- = ptr%
- _heap_release(
- ptr%)
- maxfree%,nrpages%,flags%
- Returns 0 if block released OK
- Returns -1 if operation failed (i.e. block doesn't exist)
- "XOS_Module",7,,ptr%
- ;flags%:
- Free the block
- (flags%
- 1) = 0
- Block was released successfully...
- ptr% = 0
- Error occured trying to free the block, return -1 to signal to the
- program that something went wrong (normally the program would ignore
- this anyway)
- ptr% = -1
- --- File Handling Routines --------------------------------------------
- FileLength(object$)
- type%,load_addr%,exec_addr%,length%,atts%,string$
- "OS_File",5,object$
- type%,,load_addr%,exec_addr%,length%,atts%
- =length%
-